import axios from 'axios';
import qs from 'querystring';
import _ from 'lodash';
import queryString from 'qs';

// 资产识别列表
export const getAssetCategory = params => {
  return axios.get(`/api/knowledge/assetCategories?${qs.stringify(params)}`);
};
// 资产识别表子类列表
export const getAssetCategoryComponent = body => {
  return axios.post('/api/knowledge/list', body);
};
// 资产识别表详情
export const getAssetCategoryDetail = params => {
  return axios.get(`/api/knowledge/info?${queryString.stringify(params)}`);
};
// 删除资产识别表子级别
export const postAssetCategoryDelete = body => {
  return axios.post('/api/knowledge/delete', body);
};

// 自定义指纹列表
export const getCustomList = params => {
  return axios.get(
    `/api/fingerprint/custom/list?${queryString.stringify(_.pickBy(params, Boolean), {
      arrayFormat: 'repeat'
    })}`
  );
};

// 新增自定义指纹
export const postCustomAdd = body => {
  return axios.post('/api/fingerprint/custom/add', body);
};
// 编辑自定义指纹
export const postCustomModify = body => {
  return axios.post('/api/fingerprint/custom/modify', _.omitBy(body, _.isNil));
};
// 删除自定义指纹
export const deleteCustom = body => {
  return axios.delete('/api/fingerprint/custom', { data: body });
};
// 批量编辑
export const postCustomStatus = body => {
  return axios.post('/api/fingerprint/custom/modify/status/batch', body);
};
// 自定义指纹数量
export const getCustomSum = () => {
  return axios.get('/api/fingerprint/custom/info');
};

// 新增指纹知识库
export const postKnowledgeAdd = body => {
  return axios.post('/api/knowledge/create', body);
};

// 修改指纹知识库
export const postKnowledgeUpdate = body => {
  return axios.post('/api/knowledge/update', body);
};
